// 输入 '田'，要匹配出广东省深圳市福田区

const regions = [
  {
    name: '北京市',
    children: [
      { name: '朝阳区' },
      { name: '海淀区' },
    ],
  },
  {
    name: '广东省',
    children: [
      {
        name: '深圳市',
        children: [
          { name: '南山区' },
          { name: '福田区' },
        ],
      },
      {
        name: '广州市',
        children: [
          { name: '天河区' },
          { name: '越秀区' },
        ],
      },
    ],
  },
];

// 使用示例
console.log(searchRegions(regions, '田'));
// 输出: [ '广东省深圳市福田区' ]
function searchRegions(arr, str) {
    //let rag = match(str) //正则匹配
    let matchArr = []
    for(let i = 0; i < arr.length; i++){
        if (arr[i].name.inludes(str)){
            matchArr.push(arr[i])
        } else {
            //递归调用
            searchRegions(arr[i].children)
        }
    }
    return matchArr.join('')
}





console.log('A');

setTimeout(() => {
  console.log('B');
  queueMicrotask(() => console.log('C'));
}, 0);

Promise.resolve().then(() => {
  console.log('D');
  setTimeout(() => {
    console.log('E');
    Promise.resolve().then(() => {
      console.log('F');
    });
  }, 0);
});

(async () => {
  console.log('G');
  await null;
  console.log('H');
})();

queueMicrotask(() => {
  console.log('I');
});

console.log('J');
A,G,J,D,H,I,B,C,E,F
